<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 将数组[2,0,6,1,77,0,52,0,25,7]中大于等于10的元素选出来,放入新数组
        var arr3 = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];
        var newArr = [];
        for (var i = 0; i < arr3.length; i++) {
            if (arr3[i] >= 10) {
                //新数组应该从0开始递增
                newArr[newArr.length] = arr3[i];
                // newArr.length起始长度为0
                // 增加一个数组,.length就增加一
            }
        }
        console.log(newArr);

        // 数组案例练习
        // 将数组[2,0,6,1,77,0,52,0,25,7]中的0去掉后,形成一个不包含0的新数组。
        var arr = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];
        var arr2 = [];
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] != 0) {
                arr2[arr2.length] = arr[i];
            }
        }
        console.log(arr2);

        // 将数组['red','green','blue','pitk','purple']的内容反过来存放。
        var arr4 = ['red', 'green', 'blue', 'pitk', 'purple'];
        var newArr4 = [];
        for (var i = arr4.length - 1; i >= 0; i--) {
            newArr4[newArr4.length] = arr4[i];
        }
        console.log(newArr4);
    </script>
</head>

<body>

</body>

</html>